


/**
 * 用户表单类型
 */
interface UserInfoType{
    userCount?:string,
    userEmail?:string,
    userPassword:string,
    userPhone?:string,
    userSex?:number,
    userId?:string
}

/**
 * 用户登录表单类型
 */
interface  userLoginFormType{

    username:string,
    password:string
}


/**
 * 检验参数
 * @param data
 */
export  function userLoginCheckFuntion(data:userLoginFormType):Promise<UserInfoType>{

    return new Promise(resolve => {
        //手机号正则
        let phoneValied=/^(?:(?:\+|00)86)?1\d{10}$/;
        //邮箱正则
        let emailRE = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

        let userForm={
            userCount:"",
            userEmail:"",
            userPassword:"",
            userPhone:"",}
        userForm.userPassword=data.password;
        if(data.username.match(emailRE)){
            userForm.userEmail=data.username;}
        else if(data.username.match(phoneValied)){
            userForm.userPhone=data.username
        }
        else {
            userForm.userCount=data.username;
        }

        resolve(userForm);
    })
}
